package com.example.controller;

import com.example.common.result.Result;
import com.example.entity.hz.Printmodule;
import com.example.entity.hz.Printtemplate;
import com.example.service.PrintmoduleService;
import com.example.service.PrinttemplateService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

@Slf4j
@Api(tags = "打印模块管理前端控制器")
@RestController
@RequestMapping("/api/Printmodule")
public class PrintmoduleController {

    //打印模块中间实现层
    @Resource
    private PrintmoduleService printmoduleService;

    //打印模版中间实现层
    @Resource
    private PrinttemplateService printtemplateService;

    @ApiOperation("新增打印模块 批量或单独")
    @PostMapping("/savePrintModule")
    public Result savePrintModule(@RequestBody List<Printmodule> printmoduleList){
        return this.printmoduleService.savePrintModule(printmoduleList);
    }

    @ApiOperation("打印模块通过主键uuid进行删除 批量或单独")
    @PostMapping("/deletePrintModule")
    public Result deletePrintModule(@RequestBody List<Integer> uuidList){
        return this.printmoduleService.deletePrintModule(uuidList);
    }

    @ApiOperation("打印模块分页查询")
    @PostMapping("/queryPrintModuleIPage/{current}/{size}")
    public Result<Map<String,Printmodule>> queryPrintModuleIPage(@PathVariable Integer current,@PathVariable Integer size){
        return this.printmoduleService.queryPrintModuleIPage(current,size);
    }

    @ApiOperation("通过uuid查询到绑定的打印模版")
    @GetMapping("/queryPrintTemplateList/{uuid}")
    public Result<List<Printtemplate>> queryPrintTemplateList(@PathVariable Integer uuid){
        return this.printtemplateService.queryPrintTemplateList(uuid);
    }

    @ApiOperation("通过主键uuid查询到打印模块的详情信息")
    @GetMapping("/queryOnePrintTemplate/{uuid}")
    public Result<Printmodule> queryOnePrintTemplate(@PathVariable Integer uuid){
        return this.printmoduleService.queryOnePrintTemplate(uuid);
    }

    @ApiOperation("修改打印模块")
    @PostMapping("/updatePrintModule")
    public Result updatePrintModule(@RequestBody Printmodule printmodule){
        return this.printmoduleService.updatePrintModule(printmodule);
    }

}
